package com.hebeu.device.service.impl;

import com.hebeu.device.dao.DServiceMapper;
import com.hebeu.device.pojo.DService;
import com.hebeu.device.pojo.DServiceExample;
import com.hebeu.device.pojo.view.ViewService;
import com.hebeu.device.service.NotifyRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Description 报修管理实现类
 * @Author 言立慧
 * @Date 2019/6/16 19:18
 */
@Service
public class NotifyRepairServiceImpl implements NotifyRepairService {
    private DServiceMapper dServiceMapper;

    @Autowired
    public NotifyRepairServiceImpl(DServiceMapper dServiceMapper) {
        this.dServiceMapper = dServiceMapper;
    }

    @Override
    public List<DService> selectAllDServices() {
        List<DService> dServices = dServiceMapper.selectByExample(new DServiceExample());
        return dServices;
    }

    @Override
    public void addService(DService service) {
        dServiceMapper.insertSelective(service);
    }

    @Override
    public void updateService(DService dService) {
        dServiceMapper.updateByPrimaryKeySelective(dService);
    }

    @Override
    public DService setService(int size, ViewService viewService) {
        Integer serviceId = size;
        DService service = new DService();
        service.setsId(serviceId);
        service.setcName(viewService.getcName());
        service.setAlterTime(new Date());
        service.setCreateTime(new Date());
        service.setEstimate(viewService.getEstimate());
        service.setStartTime(new Date());
        service.setEndTime(viewService.getEndTime());
        service.setsStatus(0);
        return service;
    }

    @Override
    public DService getServiceById(Integer serviceId) {
        return dServiceMapper.selectByPrimaryKey(serviceId);
    }
}
